home *** CD-ROM | disk | FTP | other *** search
- #include <exec/execbase.h>
- #include <intuition/intuition.h>
- #include <intuition/intuitionbase.h>
- #include <graphics/text.h>
- #include <dos/rdargs.h>
- #include <dos/dos.h>
- #include <clib/dos_protos.h>
- #include <clib/intuition_protos.h>
-
- #define EXTRASPACE 16
-
- extern struct ExecBase *SysBase;
- extern struct IntuitionBase *IntuitionBase;
-
- char version[] = "$VER: PatchMenu 1.3 David Göhler (15.11.94)\n";
- char ArgStr [] = "WINDOWNAME/A,MENU/A,MENUITEM/A,CHAR/A,S=SCREEN/K,SUB=SUBITEM/K,V=VERBOSE/S,CW=CORRECTWIDTH/S";
- LONG ArgArray [8] = { 0,0,0,0,0,0,0,0 };
-
- int main(int argc, char *argv[])
- {
- int retcode = RETURN_OK;
- struct RDArgs *rda = NULL;
- struct Window *win = 0;
- struct Screen *scr = 0;
-
- if (SysBase->LibNode.lib_Version < 37) return 20;
-
- memset(ArgArray,0,sizeof(LONG)*7);
-
- if (rda = ReadArgs(ArgStr,ArgArray,rda))
- {
- scr = LockPubScreen((STRPTR)(ArgArray[4]));
- win = scr->FirstWindow;
-
- while (win != 0)
- {
- if (ArgArray[6] != 0)
- { Printf("Window: %s\n",(long)(win->Title)); }
-
- if (stricmp(win->Title,ArgArray[0]))
- { win = win->NextWindow;
- continue;
- }
-
- if (win == 0) { retcode = RETURN_FAIL; break; }
- else
- { struct Menu *menu = win->MenuStrip;
-
- if (menu == 0)
- { win = win->NextWindow;
- continue;
- }
-
- while ((menu != 0) && (stricmp(ArgArray[1],menu->MenuName)))
- {
- if (ArgArray[6] != 0)
- { Printf(" Menu: %s\n",(long)(menu->MenuName)); }
- menu = menu->NextMenu;
- }
-
- if (menu == 0) retcode = RETURN_FAIL + 1;
- else
- { struct MenuItem *item = menu->FirstItem;
-
- if (ArgArray[6] != 0)
- { Printf(" Menu: %s\n",(long)(menu->MenuName)); }
-
- while ((item != 0) && (stricmp(ArgArray[2],((struct IntuiText *)(item->ItemFill))->IText)))
- {
- if (ArgArray[6] != 0)
- { Printf(" Item: %s\n",(long)(((struct IntuiText *)(item->ItemFill))->IText)); }
- item = item->NextItem;
- }
-
- if ((item != 0) && (ArgArray[6] != 0))
- { Printf(" Item: %s\n",(long)(((struct IntuiText *)(item->ItemFill))->IText)); }
-
- if ((ArgArray[5] != 0) && (item != 0)) // SubItem gefordert
- { item = item->SubItem;
-
- while ((item != 0) && (stricmp(ArgArray[5],((struct IntuiText *)(item->ItemFill))->IText)))
- {
- if (ArgArray[6] != 0)
- { Printf(" SubItem: %s\n",(long)(((struct IntuiText *)(item->ItemFill))->IText)); }
- item = item->NextItem;
- }
- }
-
- if (CheckSignal(SIGBREAKF_CTRL_C) == SIGBREAKF_CTRL_C)
- { retcode = RETURN_WARN;
- break;
- }
-
- if (item == 0) retcode = RETURN_FAIL + 2;
- else
- {
- if (ArgArray[6] != 0)
- { Printf(" Item: %s\n",(long)(((struct IntuiText *)(item->ItemFill))->IText)); }
-
- if (strlen(ArgArray[3]) > 0)
- { item->Flags |= COMMSEQ;
- item->Command = *(char *)(ArgArray[3]);
- if (ArgArray[7])
- { item->Width += COMMWIDTH + EXTRASPACE; }
- }
- else
- { if (ArgArray[7])
- { item->Width -= COMMWIDTH + EXTRASPACE; }
- item->Flags &= ~COMMSEQ;
- }
- }
- }
- break;
- }
- }
-
- UnlockPubScreen(0,scr);
- FreeArgs(rda);
- }
- else
- { PrintFault(IoErr(),argv[0]);
- retcode = RETURN_FAIL;
- }
-
- return retcode;
- }
-